<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Websocket客户端示例</title>
</head>
<body>
<script>
    var ws = new WebSocket('ws://localhost:3000/ws');
    ws.onmessage = function (e) {
        console.log('_message', e.data);
    };
    ws.onerror = function (err) {
        console.log('_error', err);
    };
    ws.onopen = function () {
        console.log('_connect')
    };
    ws.onclose = function () {
        console.log('_close');
    };
    // ws.send('test message data'); // 测试发送消息
</script>
</body>
</html>